﻿using SAD_Assignment1.DAO;
using SAD_Assignment1.DTO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace SAD_Assignment1.BLO
{
    public class CommentBLO
    {
        public List<CommentDTO> getAllComment(int photoID)
        {
            CommentDAO cmtDAO = new CommentDAO();
            List<CommentDTO> result = new List<CommentDTO>();
            List<CommentDTO> cmtList = cmtDAO.getComment(photoID);
            foreach (var cmt in cmtList)
            {
                result.Add(cmt);
                List<CommentDTO> replyList = cmtDAO.getReply(cmt.ID);
                result.AddRange(replyList);
            }
            return result;
        }

        public bool AddComment(int photoID, string body, string email)
        {
            CommentDAO cmtDAO = new CommentDAO();
            return cmtDAO.addComment(photoID, body, email);
        }

        public bool DeleteComment(int cmtID)
        {
            CommentDAO cmtDAO = new CommentDAO();
            return cmtDAO.DeleteComment(cmtID);
        }

        public bool AddReply(int cmtID, string body, string email)
        {
            CommentDAO cmtDAO = new CommentDAO();
            return cmtDAO.AddReply(cmtID, body, email);
        }

        public bool DeleteReply(int replyID)
        {
            CommentDAO cmtDAO = new CommentDAO();
            return cmtDAO.DeleteReply(replyID);
        }
    }
}